package com.yunduo;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.io.BufferedReader;
import java.io.FileReader;

/**
 * 云朵网站
 * @Author 晨心
 */

@SpringBootApplication
@MapperScan(basePackages = {"com.yuduo.mapper"})
@EnableScheduling
public class YunDuoApplication implements ApplicationRunner {
    public static void main(String[] args) {
        SpringApplication.run(YunDuoApplication.class,args);
    }

    //加载完毕后打印欢迎界面
    @Override
    public void run(ApplicationArguments args) throws Exception {
        //获取resource目录下的文件
        String filePath = this.getClass().getClassLoader().getResource("").getPath()+"welcome/welcome.txt";
        BufferedReader in = new BufferedReader(new FileReader(filePath));
        if(null == in){
            System.out.println("加载欢迎文件失败");
        }
        String data;
        while ((data = in.readLine()) != null){
            System.out.println("\u001B[32m"+data+"\u001B[0m");
        }
    }
}
